~ chicken-core (chicken-5) /manual/Module (chicken process-context posix)
Trap1[[tags: manual]]2[[toc:]]34== Module (chicken process-context posix)56This module provides access to POSIX-specific procedures which deal7with the current process context.89* New in CHICKEN 5.4.0: Errors caused by underlying C calls that10 change errno will produce a condition object with an {{errno}}11 property, which can be accessed with12 {{(get-condition-property <the-condition-object> 'exn 'errno)}}.1314=== Process filesystem context1516==== change-directory*1718<procedure>(change-directory* FD)</procedure>19<procedure>(set! (current-directory) FD)</procedure>2021Changes the current working directory to the one represented by the22file-descriptor {{FD}}, which should be an exact integer.2324'''NOTE''': Windows does not allow {{{open}}} on directories, so while25technically it is supported, in practice you cannot use this procedure26on native Windows builds (on cygwin it works because cygwin emulates27this).2829==== set-root-directory!3031<procedure>(set-root-directory! STRING)</procedure>3233Sets the root directory for the current process to the path given in34{{STRING}} (using the {{chroot}} function). If the current process35has no root permissions, the operation will fail.3637'''NOTE''': On native Windows builds (all except cygwin), this38procedure is unimplemented and will raise an error.394041=== Retrieving user & group information4243==== current-user-id4445<procedure>(current-user-id)</procedure>46<setter>(set! (current-user-id) UID)</setter>4748Get or set the real user-id of the current process. The procedure corresponds to the getuid and setuid C functions.4950'''NOTE''': On native Windows builds (all except cygwin), this51procedure is unimplemented and will raise an error.5253==== current-user-name5455<procedure>(current-user-name)</procedure>5657Get the login name corresponding to the real user-id of the current58process from the system password database.5960On Windows, there's no user-id and no distinction between real and61effective user, but this procedure ''will'' return the username62associated with the current process, so it is safe to use.636465==== current-effective-user-id6667<procedure>(current-effective-user-id)</procedure>68<setter>(set! (current-effective-user-id) UID)</setter>6970Get or set the effective user-id of the current process.7172'''NOTE''': On native Windows builds (all except cygwin), this73procedure is unimplemented and will raise an error.7475==== current-effective-user-name7677<procedure>(current-effective-user-name)</procedure>7879Get the login name corresponding to the effective user-id of the80current process from the system password database.8182'''NOTE''': On native Windows builds (all except cygwin), this83procedure is unimplemented and will raise an error.8485==== current-group-id8687<procedure>(current-group-id)</procedure>88<setter>(set! (current-group-id) GID)</setter>8990Get or set the real group-id of the current process.9192'''NOTE''': On native Windows builds (all except cygwin), this93procedure is unimplemented and will raise an error.9495==== current-effective-group-id9697<procedure>(current-effective-group-id)</procedure>98<setter>(set! (current-effective-group-id) GID)</setter>99100Get or set the effective group-id of the current process.101ID can be found, then {{#f}} is returned.102103'''NOTE''': On native Windows builds (all except cygwin), this104procedure is unimplemented and will raise an error.105106107=== Process identity108109==== current-process-id110111<procedure>(current-process-id)</procedure>112113Returns the process ID of the current process.114115==== parent-process-id116117<procedure>(parent-process-id)</procedure>118119Returns the process ID of the parent of the current process.120121'''NOTE''': On native Windows builds (all except cygwin), this122procedure is unimplemented and will raise an error.123124==== process-group-id125126<procedure>(process-group-id PID)</procedure>127<setter>(set! (process-group-id PID) PGID)</setter>128129Get or set the process group ID of the process specified by {{PID}}.130131'''NOTE''': On native Windows builds (all except cygwin), this132procedure is unimplemented and will raise an error.133134==== create-session135136<procedure>(create-session)</procedure>137138Creates a new session with the current process as group leader. Returns current process id on success. Equivalent to setsid(2).139140==== user-information141142<procedure>(user-information USER [AS-VECTOR])</procedure>143144If {{USER}} specifes a valid username (as a string) or user ID, then145the user database is consulted and a list of 7 values are returned:146the user-name, the encrypted password, the user ID, the group ID, a147user-specific string, the home directory and the default shell. When148{{AS-VECTOR}} is {{#t}} a vector of 7 elements is returned instead of149a list. If no user with this name or id then {{#f}} is returned.150151Note: on Android systems, the user-specific string is always {{""}},152since {{pw_gecos}} is not available in the C {{passwd}} struct on that153platform.154155'''NOTE''': On native Windows builds (all except cygwin), this156procedure is unimplemented and will raise an error.157158---159Previous: [[Module (chicken process-context)]]160161Next: [[Module (chicken random)]]